﻿using DropBoxClient.Entities;
using DropBoxClient.Framework;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;

namespace DropBoxClient.Operations
{
    internal class MoveOperation
    {
        private static readonly string Url = "https://api.dropbox.com/1/fileops/move";
        private static readonly string MethodType = StringConstants.PostMethodType;

        private WebOperation<Meta> _operation;
        private string _accessToken;

        internal string Root { get; set; }
        internal string FromPath { get; set; }
        internal string ToPath { get; set; }

        internal MoveOperation(string accessToken)
        {
            _accessToken = accessToken;
        }

        internal Meta Execute()
        {
            var parameterCollection = new NameValueCollection();
            parameterCollection.Add("root", Root);
            parameterCollection.Add("from_path", FromPath);
            parameterCollection.Add("to_path", ToPath);
            _operation = new WebOperation<Meta>(Url, _accessToken, MethodType, parameterCollection);
            return _operation.Execute();
        }
    }
}
